<html>
<head>
    <title>新增新闻</title>
</head>
<body>
<h1>新增新闻</h1>
<form action="save" method="post" onsubmit="return mya()">
    <input name="title" id="title" placeholder="请输入新闻内容"/><br/>
    <select name="categoryId" id="categoryName">
        <option value="">请选择</option>
        <option th:each="a:${cs}"
                th:value="${a.categoryId}"
                th:text="${a.categoryName}"></option>
    </select><a th:href="@{toAddType}">新增类别</a>
    <br/>
    <input type="submit"/>
</form>
<script>
    function mya(){
        // alert("哈喽");
        //根据id获取到输入框的值
        var t=document.getElementById("title").value;
        var s=document.getElementById("categoryName").value;
        if(t==null||t==''&&s==null||s==''){
            alert("请输入新闻内容&请选择新闻类别")
            return false;
        }else{
            return true;
        }
    }
</script>
</body>
</html>
